<template>
  <nav>
    <span class="city" @click="goToCity">{{ cityname }}</span>

    <ul>
      <router-link
        class="li"
        v-for="item in navList"
        :key="item.title"
        :to="'/home/movies' + item.url"
      >
        {{ item.title }}
      </router-link>
    </ul>

    <span class="iconfont icon-sousuo"></span>
  </nav>
</template>

<script>
// import { mapState } from "vuex";
export default {
  data() {
    return {
      navList: [
        {
          title: "热映",
          url: "/hot",
        },
        {
          title: "影院",
          url: "/cinema",
        },
        {
          title: "待映",
          url: "/wait",
        },
        {
          title: "经典电影",
          url: "/classic",
        },
      ],
      active: "热映",
    };
  },
  computed: {
    cityname() {
      return this.$store.state.city.cityname;
    },
  },
  // computed: mapState(["cityname"]),
  methods: {
    goToCity() {
      this.$router.push("/city");
    },
  },
};
</script>

<style lang="less" scoped>
nav {
  width: 100%;
  height: 46px;
  background-color: #fff;
  border-bottom: 1px solid @border-color;
  display: flex;
  font-size: @m-font;

  .city {
    width: 62px;
    .center();
  }

  ul {
    flex: 1;
    display: flex;
    padding: 0 20px;

    .li {
      flex: 2;
      .center();

      &:last-child {
        flex: 3;
      }
    }

    .router-link-active {
      font-weight: 900;
      position: relative;

      &::after {
        content: "";
        position: absolute;
        width: 20px;
        height: 3px;
        background-color: @theme-color;
        left: 50%;
        transform: translateX(-50%);
        bottom: 4px;
        border-radius: 1.5px;
      }
    }
  }

  .icon-sousuo {
    width: 45px;
    .center();
    color: @theme-color;
    font-size: @xl-font;
  }
}
</style>
